/*
 ============================================================================
 Name        : Condition.c
 Author      : 
 Version     :
 Copyright   : Your copyright notice
 Description : Hello World in C, Ansi-style
 ============================================================================
 */

#include <stdio.h>
#include <stdlib.h>
#include "precon.h"
#include <assert.h>
#include <math.h>
#include <stdbool.h>
#include <stdarg.h>
#include <string.h>



double isqrt(double x) {
	preCondition(x, "x = 1", "x = 2", "x = 3", "x = 4", "x = 5", "x = 6","x = 7", "ende"); //wenn   while (strcmp(fmt1,"ende") != 0);
	//preCondition(x, "x = 1", "x = 2", "x = 3", "x = 4", "x = 5", "x = 6","x = 7", "0"); //wenn  while (*fmt1 != 48);}
	return sqrt(x);
}


void preCondition(int cond, char *fmt1, ...) {

	va_list zeiger;
	int i = 1;
	va_start(zeiger, fmt1);

	do {
		if (i == cond) {
			printf("\nPreCondition: %s", fmt1);
			assert(cond);
		}
		fmt1 = va_arg(zeiger,char*);

		printf("\n i = %d", i);
		i++;

//	} while (*fmt1 != 48);}
	}	while (strcmp(fmt1,"ende") != 0);
	va_end(zeiger);

}


int main(void) {

	char* a = "12345";
	double x = 3;
	a++;
	a++;
	printf("\nwurzel aus %2.0f = %2.3f", x, isqrt(x));
	printf("\n char a =%s", a);
	printf("\n char a =%d", *a-48);
	return EXIT_SUCCESS;

}

